﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Newtonsoft.Json;

namespace Ccit.OA.Scheduler
{
    public partial class scheduler_agent_list : Ccit.Utils.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DataBindView();
        } 
        private void DataBindView()
        {
            SchedulerBLL Bll = new SchedulerBLL();
            DataSet dSet = Bll.GetSchProxyMes("");
            if(dSet.Tables[0].Rows.Count>0)
            { dgMain.DataSource = dSet; }
            else
            { dgMain.DataSource = null; }
            dgMain.DataBind();
        }

        protected void dgMain_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs e)
        {
            if (e.RowType != DevExpress.Web.ASPxGridView.GridViewRowType.Data) return;
            string userId = dgMain.GetRowValues(e.VisibleIndex, "userId").ToString();
            string proxyId = dgMain.GetRowValues(e.VisibleIndex, "proxyId").ToString();
            string modifyFlag = dgMain.GetRowValues(e.VisibleIndex, "modifyFlag").ToString();
            HtmlAnchor lnbDel = (HtmlAnchor)dgMain.FindRowCellTemplateControl(e.VisibleIndex, null, "lnbDel");
            lnbDel.Attributes["href"] = "javascript:doDel('" + userId + "'," + proxyId + ")";
            if (modifyFlag == "0")
            {
                e.Row.Cells[6].Text = "否";
            }
            else
            {
                e.Row.Cells[6].Text = "是";
            }
        }

        protected void lnbQuery_Click(object sender, EventArgs e)
        {
            DataBindView();
        }
        #region Ajax Methods
        [global::System.Web.Services.WebMethod]
        public static string DoOperate(string strJson)
        {
            SchedulerBLL Bll = new SchedulerBLL();
            MsSchProxy ms = (MsSchProxy)JavaScriptConvert.DeserializeObject(strJson, typeof(MsSchProxy));
            string iNum = Bll.DoOperateProxy(ms); 
            Bll = null;
            return iNum;
        }
        #endregion
    }
}
